hostnamectl set-hostname cloud

#配置ubuntu源
cp /etc/apt/sources.list /etc/apt/sources.list.bak

apt update

#安装docker
apt install docker.io
systemctl daemon-reload
systemctl restart docker
docker --version

#安装go
scp install.sh root@cloud:/root
scp g1.2.1.linux-amd64.tar.gz root@cloud:/root

bash install.sh
source ~/.bashrc 

g install 1.17.6

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct

#安装kind
go install sigs.k8s.io/kind@v0.11.1

vim ~/.bashrc
export PATH="/root/go/bin:$PATH"
source ~/.bashrc
#kind启动
vim kind-cluster.yaml

apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker

kind create cluster --config kind-cluster.yaml

#下载yurt-cluster
git clone https://github.com.cnpmjs.org/openyurtio/yurtcluster-operator


#安装helm
scp helm-v3.8.0-rc.2-linux-amd64.tar.gz root@cloud:/

tar -zxvf helm-v3.8.0-rc.2-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm

#安装kubectl
curl -LO https://dl.k8s.io/release/v1.23.0/bin/linux/amd64/kubectl
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl


#验证kind node
kubectl get node

#helm install
cd yurtcluster-operator/charts
helm install yurtcluster-operator . -n kube-system

#查看状态
kubectl get pod -n kube-system | grep yurt

#标记节点
kubectl label node kind-worker openyurt.io/node-type=cloud
kubectl label node kind-worker2 openyurt.io/node-type=edge
kubectl label node kind-worker3 openyurt.io/node-type=edge

#部署 YurtCluster CR 对象
vim yurtcluster.yaml

apiVersion: operator.openyurt.io/v1alpha1
kind: YurtCluster
metadata:
  name: cluster
spec:
  yurtVersion: "v0.5.0"
  cloudNodes:
    selector:
      nodeSelectorTerms:
        - matchExpressions:
            - key: openyurt.io/node-type
              operator: In
              values:
                - "cloud"
  edgeNodes:
    selector:
      nodeSelectorTerms:
        - matchExpressions:
            - key: openyurt.io/node-type
              operator: In
              values:
                - "edge"


kubectl apply -f yurtcluster.yaml


#查看状态
kubectl get yc
kubectl get pod -n kube-system | grep yurt-hub
kubectl get pod -n kube-system | grep yurt-tunnel

kubectl logs -f -n kube-system yurt-tunnel-agent-5fxz6
kubectl logs -f -n kube-system yurt-hub-kind-worker
